
<script type="text/javascript">
$(document).ready(function(e)
{


    //$('#message').hide();

     var opciones= {
                               success: showSuccess, //funcion que se ejecuta una vez enviado el formulario
                               error:showError
            };

    $('#login').ajaxForm(opciones);



  //************************************************
 function showSuccess (data, textStatus, jqXHR){

               if(data!="")
               {
                 var objeto=JSON.parse(data);
                 console.log("objeto"+objeto);
                 if(objeto.result=='ERROR')
                 {
                   console.log("Erro usuario o contraseña");
                   $h2=$("<h2>"+objeto.message+"</h2>");
                   $('#message').html("");
                   $('#message').append($h2);
                   $('#username').val('');
                   $('#password').val('');
                   $('#username').focus();



                 }else
                 {

                    if(objeto.result="OK")
                    {

                      console.log("Usuario Correcto");

                       $h2=$("<h2>"+objeto.message+"</h2>");
                       $('#message').html("");
                       $('#message').append($h2);
                       $('#username').val('');
                       $('#password').val('');
                       $('#username').focus();
                       document.location.href="<?php echo site_url('"+objeto.redirect+"');?>";
                    }
                 }
                       
                          
             }
         };


 function showError()
 {


 }
});


</script>




<style>


body {
    background-color: #D9DEE2;
    background-image: -moz-linear-gradient(center top , #EBEEF2, #D9DEE2);
    font: 12px 'Lucida Sans Unicode','Trebuchet MS',Arial,Helvetica;
    margin: 0;
}


html, body {
    height: 100%;
}


#login:before {
    border: 1px dashed #CCCCCC;
    bottom: 5px;
    box-shadow: 0 0 0 1px #FFFFFF;
    content: "";
    left: 5px;
    position: absolute;
    right: 5px;
    top: 5px;
    z-index: -1;
}
#login {
    background-color: #FFFFFF;
    background-image: -moz-linear-gradient(center top , #FFFFFF, #EEEEEE);
    border-radius: 3px 3px 3px 3px;
    box-shadow: 0 0 2px rgba(0, 0, 0, 0.2), 0 1px 1px rgba(0, 0, 0, 0.2), 0 3px 0 #FFFFFF, 0 4px 0 rgba(0, 0, 0, 0.2), 0 6px 0 #FFFFFF, 0 7px 0 rgba(0, 0, 0, 0.2);
    height: 240px;
    left: 50%;
    margin: -150px 0 0 -230px;
    padding: 30px;
    position: absolute;
    top: 50%;
    width: 400px;
    z-index: 0;
}

h1
{
    text-shadow: 0 1px 0 rgba(255, 255, 255, .7), 0px 2px 0 rgba(0, 0, 0, .5);
    text-transform: uppercase;
    text-align: center;
    color: #666;
    margin: 0 0 30px 0;
    letter-spacing: 4px;
    font: normal 26px/1 Verdana, Helvetica;
    position: relative;
}

h1:after, h1:before
{
    background-color: #777;
    content: "";
    height: 1px;
    position: absolute;
    top: 15px;
    width: 40px;   
}

h1:after
{ 
    background-image: -webkit-gradient(linear, left top, right top, from(#777), to(#fff));
    background-image: -webkit-linear-gradient(left, #777, #fff);
    background-image: -moz-linear-gradient(left, #777, #fff);
    background-image: -ms-linear-gradient(left, #777, #fff);
    background-image: -o-linear-gradient(left, #777, #fff);
    background-image: linear-gradient(left, #777, #fff);      
    right: 0;
}

h1:before
{
    background-image: -webkit-gradient(linear, right top, left top, from(#777), to(#fff));
    background-image: -webkit-linear-gradient(right, #777, #fff);
    background-image: -moz-linear-gradient(right, #777, #fff);
    background-image: -ms-linear-gradient(right, #777, #fff);
    background-image: -o-linear-gradient(right, #777, #fff);
    background-image: linear-gradient(right, #777, #fff);
    left: 0;
}

/*--------------------*/

fieldset
{
    border: 0;
    padding: 0;
    margin: 0;
}

/*--------------------*/

#inputs input
{
    background: #f1f1f1 url('../img/login/login-sprite.png') no-repeat;
    padding: 15px 15px 15px 30px;
    margin: 0 0 10px 0;
    width: 353px; /* 353 + 2 + 45 = 400 */
    border: 1px solid #ccc;
    -moz-border-radius: 5px;
    -webkit-border-radius: 5px;
    border-radius: 5px;
    -moz-box-shadow: 0 1px 1px #ccc inset, 0 1px 0 #fff;
    -webkit-box-shadow: 0 1px 1px #ccc inset, 0 1px 0 #fff;
    box-shadow: 0 1px 1px #ccc inset, 0 1px 0 #fff;
}

#username
{
    background-position: 5px -2px !important;
}

#password
{
    background-position: 5px -52px !important;
}

#inputs input:focus
{
    background-color: #fff;
    border-color: #e8c291;
    outline: none;
    -moz-box-shadow: 0 0 0 1px #e8c291 inset;
    -webkit-box-shadow: 0 0 0 1px #e8c291 inset;
    box-shadow: 0 0 0 1px #e8c291 inset;
}

/*--------------------*/
#actions
{
    margin: 2px 0 0 0;
}

#submit {
    background-color: #FFB94B;
    background-image: -moz-linear-gradient(center top , #FDDB6F, #FFB94B);
    border-color: #D69E31 #E3A037 #D5982D;
    border-radius: 3px 3px 3px 3px;
    border-style: solid;
    border-width: 1px;
    box-shadow: 0 0 1px rgba(0, 0, 0, 0.3), 0 1px 0 rgba(255, 255, 255, 0.3) inset;
    color: #8F5A0A;
    cursor: pointer;
    float: left;
    font: bold 15px Arial,Helvetica;
    height: 35px;
    padding: 0;
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5);
    width: 120px;
}

#submit:hover,#submit:focus
{   
    background-color: #fddb6f;
    background-image: -webkit-gradient(linear, left top, left bottom, from(#ffb94b), to(#fddb6f));
    background-image: -webkit-linear-gradient(top, #ffb94b, #fddb6f);
    background-image: -moz-linear-gradient(top, #ffb94b, #fddb6f);
    background-image: -ms-linear-gradient(top, #ffb94b, #fddb6f);
    background-image: -o-linear-gradient(top, #ffb94b, #fddb6f);
    background-image: linear-gradient(top, #ffb94b, #fddb6f);
} 

#submit:active
{   
    outline: none;
   
     -moz-box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5) inset;
     -webkit-box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5) inset;
     box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5) inset;    
}

#submit::-moz-focus-inner
{
  border: none;
}

#actions a
{
    color: #3151A2;    
    float: right;
    line-height: 35px;
    margin-left: 10px;
}

/*--------------------*/

#back
{
    display: block;
    text-align: center;
    position: relative;
    top: 60px;
    color: #999;
}

/* Estilo por defecto */
  input:required:invalid {
    border: 1px solid red;
  }

  input:required:valid {
    border: 1px solid green;
  }

 #message
 {
    border: 1px 1px 1px 1px;
    margin: 1px 1px 1px 1px;

 }
 #message h2
 {
    font-size: 13px;
    color: red;

 }

</style>




<form id="login" method="POST" action="<?php echo base_url();?>index.php/login/process">
<h1>Acceso Sistema</h1>

<fieldset id="inputs">
  <input type="text" name="user" id="username" placeHolder="Usuario" title="Se necesita Usuario" required autofocus="true"/>
	<input type="password" name="pass" id="password" placeHolder="Contraseña" title="Se necesita Contraseña" required />
</fieldset>


<fieldset id="actions">
<input   id="submit" type="submit" value="Enviar"/>

</fieldset>
<div id="message">
<h2></h2>
</div>
</form>

